import { getSubCategoryDataAPI } from "@/apis/category";
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";

export function useSubCategoryData() {
  const route = useRoute();
  const goodList = ref([]);
  const reqData = ref({
    categoryId: route.params.id,
    page: 1,
    pageSize: 10,
    sortField: "publishTime",
  });
  const getGoodList = async () => {
    const res = await getSubCategoryDataAPI(reqData.value);
    goodList.value = res.data.result.items;
  };
  onMounted(() => {
    getGoodList();
  });

	return {
		goodList,
		reqData,
		getGoodList,
	}
}
